package com.gongren.project.job.oss;

import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Reference;
import com.gongren.project.commons.util.JodaTimeUtils;
import com.gongren.project.commons.util.Utils;
import com.gongren.project.odd.job.rpc.api.oss.service.taskRpc.IUserInfoStatisticsTaskRpcService;
import com.gongren.project.odd.job.rpc.api.service.job.IJobTaskRpcService;
import com.gongren.project.odd.job.rpc.api.service.user.IUserRpcService;
import com.gongren.project.odd.job.rpc.api.vo.count.UserInfoStatisticsRpcVo;
import com.gongren.project.odd.job.rpc.api.vo.user.EnterpriseAgentAttributeRpcVo;
import com.gongren.project.odd.job.rpc.api.vo.user.EnterpriseUserAttributeRpcVo;

/**
 * 代理商信息统计表  每日定时往该表中存入统计数据
 * 
 * @author xpp
 * @date 2017年9月11日 上午9:23:40
 */
@Component("agentInfoCountTask")
public class AgentInfoCountTask {
	private static final Logger LOGGER = LoggerFactory.getLogger(AgentInfoCountTask.class);

	@Reference
	private IUserInfoStatisticsTaskRpcService userInfoStatisticsTaskRpcService;
	
	/**
	 * 每日凌晨2点触发，将前一天的用户注册量统计 存库
	 * @author  xpp 
	 * @date 2017年8月1日 上午10:01:43 
	 * @throws Exception
	 */
	@Transactional
//	@Scheduled(cron = "0 0 2 * * ? ")
	public void excuteAgentInfoCountTask() throws Exception {

		LOGGER.info("excuteActiveStatisticsTask 开始...");
        try {
            userInfoStatisticsTaskRpcService.findAllExcuteUserInfoStatisticsTask();

            LOGGER.info("excuteActiveStatisticsTask 结束...");
        }catch (Exception e) {
            LOGGER.error("excuteActiveStatisticsTask 异常：", e);
        }
	}
	
	/**
	 * 设置所有老代理商的spreadRegisterUrlPerson
	 * @author  xpp 
	 * @date 2017年8月1日 上午10:01:43 
	 * @throws Exception
	 */
	@Transactional
//	@Scheduled(cron = "0 0 2 * * ? ")
	public void excuteSpreadRegisterUrlPersonTask() throws Exception {

		LOGGER.info("excuteSpreadRegisterUrlPersonTask 开始...");
        try {
            userInfoStatisticsTaskRpcService.findAllExcuteSpreadRegisterUrlTask();

            LOGGER.info("excuteSpreadRegisterUrlPersonTask 结束...");
        }catch (Exception e) {
            LOGGER.error("excuteSpreadRegisterUrlPersonTask 异常：", e);
        }
	}

}

